package com.example.teaching_server.repository;

import com.example.teaching_server.entity.TeachingCategory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 教学分类数据访问层
 */
@Repository
public interface TeachingCategoryRepository extends JpaRepository<TeachingCategory, Long> {

    /**
     * 查询所有分类（按年级ID和排序号排序）
     */
    @Query("SELECT tc FROM TeachingCategory tc ORDER BY tc.gradeId ASC, tc.sortOrder ASC")
    List<TeachingCategory> findAllOrderedByGradeAndSort();

    /**
     * 根据年级ID查询分类（按排序号排序）
     */
    List<TeachingCategory> findByGradeIdOrderBySortOrderAsc(Long gradeId);
}
